//
//  SortLaoShuShiViewController.m
//  MountEverestFM
//
//  Created by dllo on 15/11/3.
//  Copyright © 2015年 chenn. All rights reserved.
//

#import "SortLaoShuShiViewController.h"
#import "CommendBestListenTableViewCell.h"
#import "BestMusicListViewController.h"
@interface SortLaoShuShiViewController ()<UITableViewDataSource,UITableViewDelegate>

@property (nonatomic ,strong)UITableView *tableView;
@property (nonatomic ,strong)NSMutableDictionary *dic;
@property (nonatomic ,strong)NSMutableArray *arr;
@end

@implementation SortLaoShuShiViewController

-(void)netWorking
{
    [NetWorkManager GET:[NSString stringWithFormat:@"http://mobile.ximalaya.com/mobile/discovery/v2/category/subjects?categoryId=%@&device=iPhone&page=1&per_page=20&position=0&scale=2&title=%@",self.strId,self.str] isCaChe:YES resultData:^(id responseObject) {
        
        self.dic=responseObject;
        self.arr=[self.dic objectForKey:@"list"];
        
        
        [self.tableView reloadData];
    } resultRrror:^(NSError *error) {
        
        
    }];
    
    
}


- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self netWorking];
    self.view.backgroundColor=[UIColor whiteColor];
    
    self.tableView=[[UITableView alloc]initWithFrame:self.view.bounds style:UITableViewStylePlain];
    self.tableView.delegate=self;
    self.tableView.dataSource=self;
    [self.view addSubview:self.tableView];
    
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return self.arr.count;
    
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    CommendBestListenTableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:@"shushi1"];
    if (!cell) {
        cell=[[CommendBestListenTableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"shushi1"];
    }
    
    cell.listenDic = [self.arr objectAtIndex:indexPath.row];
    
        
    return cell;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return FM_Screen_Pts_Width*80 + FM_Screen_Pts_Height*20;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    BestMusicListViewController *best=[[BestMusicListViewController alloc]init];
    best.bestMusicDictionary=[self.arr objectAtIndex:indexPath.row];
    
    [self.navigationController pushViewController:best animated:YES];
}





- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
